<template>
  <div class="block">
    <el-cascader
      v-model="mid"
      :options="options"
      :props="{ checkStrictly: true, value: 'mid', label: 'mname' }"
      clearable
    ></el-cascader>
    <el-button type="danger" @click="del()">删除</el-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      options: [],
      mid: [],
    };
  },
  mounted() {
    var my = this;
    my.zs();
  },
  methods: {
    del() {
      if (confirm("删除时会把其子集都删除，确认删除吗?")) {
        var my = this;
        this.$axios
          .post(
            "http://localhost:5230/api/item1/Postdelmenu?mid=" +
              my.mid[my.mid.length - 1]
          )
          .then(function (h) {
            if (h.data.h > 0) {
              alert("删除成功");
              my.zs();
            } else {
              alert("删除失败");
            }
          });
      }
    },
    zs() {
      var my = this;
      this.$axios
        .get("http://localhost:5230/api/item1/Getmenu")
        .then(function (s) {
          my.options = s.data.mod;
        });
    },
  },
};
</script>